/*
 * 文件名：IndustryTeacherBusiness.java
 * 版权：Copyright 2007-2016 517na Tech. Co. Ltd. All Rights Reserved. 
 * 描述： IndustryTeacherBusiness.java
 * 修改人：yanshu
 * 修改时间：2016年1月14日
 * 修改内容：新增
 */
package com.feichuang.chineseWoodCarving.business.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.better517na.commons.Response;
import com.better517na.javaKeyIdGenerator.DatabaseDefinition;
import com.better517na.javaKeyIdGenerator.TableDefinition;
import com.feichuang.chineseWoodCarving.business.IndustryTeacherBusiness;
import com.feichuang.chineseWoodCarving.dao.IndustryTeacherDao;
import com.feichuang.chineseWoodCarving.model.MCompanyVo;
import com.feichuang.chineseWoodCarving.model.MIndustryTeacher;
import com.feichuang.chineseWoodCarving.model.MPagerRequestVo;
import com.feichuang.chineseWoodCarving.model.MPagerResultVo;

/**
 * TODO 添加类的一句话简单描述.
 * <p>
 * TODO 详细描述
 * <p>
 * TODO 示例代码
 * 
 * <pre>
 * </pre>
 * 
 * @author yanshu
 */
@Component("industryTeacherBusiness")
public class IndustryTeacherBusinessImpl extends BaseBusinessImpl implements IndustryTeacherBusiness {

    @Resource(name = "industryTeacherDao")
    private IndustryTeacherDao industryTeacherDao;

    /**
     * {@inheritDoc}.
     */
    @Override
    public MPagerResultVo<MIndustryTeacher> selectMIndustryTeacherFuzzyQuer(MPagerRequestVo<MIndustryTeacher> pageRequest) {
        // TODO Auto-generated method stub
        int begin = (pageRequest.getCurrentpage() - 1) * pageRequest.getSize();
        int end = pageRequest.getSize();
        pageRequest.setBegin(begin);
        pageRequest.setEnd(end);
        MPagerResultVo<MIndustryTeacher> pageResponse = new MPagerResultVo<MIndustryTeacher>();
        int count = industryTeacherDao.selectMIndustryTeacherCountForFuzzyQuer(pageRequest.getDataModel());
        pageResponse.setTotalCount(count);
        pageResponse.setDataInfo(industryTeacherDao.selectMIndustryTeacherFuzzyQuer(pageRequest));
        return pageResponse;
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean insertMIndustryTeacher(MIndustryTeacher industryTeacher) {
        // TODO Auto-generated method stub
        industryTeacherDao.insertMIndustryTeacher(industryTeacher);

        // keyID生成组件（每个库每个表有自己独立的生成规则）,后面维护此代码的同学按照这个格式写就行。
        Response<?> res = new Response<MCompanyVo>();

        industryTeacher.setKeyId(keyIDFactory.NewKeyID(DatabaseDefinition.AutoRefundReport, TableDefinition.AdsManageSystemDB_PlatformInfo));
        return industryTeacherDao.insertMIndustryTeacher(industryTeacher);
        // ) {
        // res = new Response<MCompanyVo>(StatusCode.SUCCESS, "完美操作！", null);
        // } else {
        // res = new Response<MCompanyVo>(StatusCode.ERROR, "风速过大", null);
        // }
        // return res;
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean updateMIndustryTeacher(MIndustryTeacher industryTeacher) {
        // TODO Auto-generated method stub
        return industryTeacherDao.updateMIndustryTeacher(industryTeacher);
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public boolean deleteMIndustryTeacher(MIndustryTeacher industryTeacher) {
        // TODO Auto-generated method stub
        return industryTeacherDao.deleteMIndustryTeacher(industryTeacher);
    }

    /**
     * {@inheritDoc}.
     */
    @Override
    public MPagerResultVo<MIndustryTeacher> selectMIndustryTeacherForPage(MPagerRequestVo<MIndustryTeacher> pageRequest) {
        // TODO Auto-generated method stub
        int begin = (pageRequest.getCurrentpage() - 1) * pageRequest.getSize();
        int end = pageRequest.getSize();
        pageRequest.setBegin(begin);
        pageRequest.setEnd(end);
        MPagerResultVo<MIndustryTeacher> pageResponse = new MPagerResultVo<MIndustryTeacher>();
        int count = industryTeacherDao.selectMIndustryTeacherCountForPage(pageRequest.getDataModel());
        pageResponse.setTotalCount(count);
        pageResponse.setDataInfo(industryTeacherDao.selectMIndustryTeacherForPage(pageRequest));
        return pageResponse;
    }

}
